using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace ExcelSample {
    public partial class DisplayInfo : Page {
        Populate p = new Populate ("ExcelData.xls");

        protected void Page_Load (object sender, EventArgs e) {
            if (!Page.IsPostBack) {
                p.QueryRange (ref GridView1, "*", "myRange1");
            }
        }

        protected void lbQuery_SelectedIndexChanged (object sender, EventArgs e) {
            switch (lbQuery.SelectedValue) {
                case "firstName":
                    p.QueryRange (ref GridView1, "Firstname", "myRange1"); 
                    break;
                case "lastName":
                    p.QueryRange (ref GridView1, "Lastname", "myRange1");
                    break;
                case "entireRange":
                    p.QueryRange (ref GridView1, "*", "myRange1");
                    break;
                default:
                    p.QueryRange (ref GridView1, "*", "myRange1");
                    break;
            }
        }
    }
}